#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>

int main()
{
    int n = 0, m = 0, i = 0, arr[100] = { 0 }, j = 0, sum = 0, count = 0;
    scanf("%d %d", &n, &m);
    for (i = 0; i < n; i++)
    {
        arr[i] = i + 1;
    }
    for (i = 0; 1; i++)
    {
        if (arr[i] == 0)
            i = 0;
        sum++;
        if (sum == m)
        {
            sum = 0;
            count++;
            printf("%d ", arr[i]);
            if (count == n)
                break;
            for (j = i; j < n; j++)
            {
                arr[j] = arr[j + 1];
            }
            i--;
        }
    }

    return 0;
}